package juc.CAS;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicIntegerTest {
    public static void main(String[] args) {
        AtomicInteger a = new AtomicInteger(0);
//        System.out.println(a.accumulateAndGet(10, (value, x) -> value + x));
//        System.out.println(a.getAndIncrement());
//        System.out.println(a.incrementAndGet());
//        System.out.println(a.decrementAndGet());
//        System.out.println(a.getAndDecrement());
        System.out.println(a.getAndAdd(10));
//        System.out.println(a.addAndGet(-10));
//
//
//        System.out.println(a.updateAndGet(value -> value * 10));
//        System.out.println(a.getAndUpdate(value -> value - 10));


//        AtomicInteger s = new AtomicInteger(10);
//        System.out.println(s.get());
//        System.out.println(s.getAndSet(1));
//        System.out.println(s.get());
//        s.lazySet(2);
//        System.out.println(s.get());

        int p=0;
        System.out.println(a.updateAndGet(value -> value + p));
        System.out.println(a.accumulateAndGet(10, (v, x) -> v + x));
    }



}
